package com.lqian.stream.match;

import com.lqian.paging.User;

import java.util.ArrayList;
import java.util.List;

/**
 * 结束操作：anyMatch、
 */
public class All_None_Any_Match {

    public static void main(String[] args) {
        List<User> userList1 = new ArrayList<>();
        userList1.add(new User(1, "小文", "123456", 12, 0, 20000d));
        userList1.add(new User(2, "老季", "123456", 13, 0, 100000d));
        userList1.add(new User(3, "怪咖", "123456", 13, 1, 89557d));
        userList1.add(new User(4, "小六", "123456", 15, 0, 78000d));
        userList1.add(new User(5, "小刘", "123456", 14, 0, 58000d));

        //anyMatch 只要任意一个匹配条件 return true
        boolean b = userList1.stream().anyMatch(user -> user.getAge() > 16);
        System.out.println(b);

        //allMatch 所有都匹配条件 才return true
        System.out.println(userList1.stream().allMatch(user -> user.getAge() >= 13));

        //noneMatch 所有都不匹配 才return true
        System.out.println(userList1.stream().noneMatch(user -> user.getGender() == 1));

    }


}
